#include "reporttool.h"
#include "iostream"
#include "../CheckInfor/deepinfor.h"
#include "../CheckInfor/hardinfor.h"
#include "../CheckInfor/emailinfor.h"
#include "../CheckInfor/fileinfor.h"
#include "../CheckInfor/securityinfor.h"
#include "../CheckInfor/normalinfor.h"
#include "../CheckInfor/virmachineinfor.h"
#include "../CheckTool/filefilter.h"
#include "../Widget/ReportDialog/loginscene.h"
#include <QFile>
#include <QtXml/QtXml>
#include <QtXml/QDomDocument>
#include "../CheckInfor/maininfor.h"
#include "../CheckInfor/DataBase/keywordlib.h"
#include <QHostInfo>

ReportTool* ReportTool::_instance=nullptr;

ReportTool* ReportTool::GetInstance(QObject* parent){
    if(ReportTool::_instance==nullptr)
        ReportTool::_instance=new ReportTool(parent);
    return ReportTool::_instance;
}

ReportTool::~ReportTool(){

}

std::function<void()> ReportTool::GetToolFunction(Yzty::ReportToolCode code){
    std::function<void()> tool;

    return tool;
}

ReportTool::ReportTool(QObject* parent):QObject (parent){

}

void ReportTool::GetReport()//获取检查报告数据
{
    GetAllData();                       //获取所有检查信息
    GenReportInit(generalreport);       //初始化总体检查报告
    getgenreportdata();                 //获取总体检查报告详细数据
    getxml();                           //获取xml
    getgenhtml();                       //获取总体检查报告
    getdetailedhtml();                  //获取详细检查报告
    getfilehtml();                      //获取文件详细检查报告
    getgenfilehtml();                   //获取文件总体检查报告
    getgenillhtml();                    //获取总体违规报告
    getillfilehtml();                   //获取文件违规报告
}

void ReportTool::ToXmlelem(QDomElement& eleminfor, Yzty::XmlBaceInfo *infor, bool defaultflag = true) {
    QDomDocument doc;
    for(int i = 0;i<infor->GetSize();i++) {
        QDomElement elem = doc.createElement("Field");
        elem.setAttribute("Name",infor->GetKeyWords(i));
        QDomText text;
        if(defaultflag)
            text = doc.createTextNode(infor->GetDefaultInfo(i));
        else
            text = doc.createTextNode(infor->GetInfor(i));
        elem.appendChild(text);
        eleminfor.appendChild(elem);
    }
}

bool ReportTool::getxml()//获取xml，未完成
{
    QDomDocument doc;
    QDomProcessingInstruction instruction = doc.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");//设置xml头
    doc.appendChild(instruction);//传入
    QDomElement root = doc.createElement("CheckReport");//设置根结点
    root.setAttribute("version","1.0");//设置属性
    doc.appendChild(root);//传入
    QDomElement head = doc.createElement("HeadRecord");
    root.appendChild(head);//传入root结点下
    QDomElement field = doc.createElement("Field");
    field.setAttribute("Name","TaskTargetName");
    head.appendChild(field);
    QDomText text = doc.createTextNode(dialoginfor.be_check_unit);
    field.appendChild(text);
//基础信息
    QVector<QDomElement> nodes;
    for(int i=0;i<13;i++) {
        nodes.append(doc.createElement("Field"));
    }
    nodes[0].setAttribute("Name","TaskTargetDepartment"); //重新设置属性
    text = doc.createTextNode(dialoginfor.be_check_sec);
    nodes[0].appendChild(text);
    nodes[1].setAttribute("Name","TaskTargetPerson");
    text = doc.createTextNode(dialoginfor.be_check_peo);
    nodes[1].appendChild(text);
    nodes[2].setAttribute("Name","TaskCheckPerson");
    text = doc.createTextNode(dialoginfor.check_peo);
    nodes[2].appendChild(text);
    nodes[3].setAttribute("Name","Date");
    text = doc.createTextNode(dialoginfor.check_time);
    nodes[3].appendChild(text);
    nodes[4].setAttribute("Name","Province");
    text = doc.createTextNode(dialoginfor.check_time);
    nodes[4].appendChild(text);
    nodes[5].setAttribute("Name","City");
    text = doc.createTextNode(dialoginfor.region);
    nodes[5].appendChild(text);
    nodes[6].setAttribute("Name","Region");
    text = doc.createTextNode(dialoginfor.check_time);
    nodes[6].appendChild(text);
    nodes[7].setAttribute("Name","SupName");
    text = doc.createTextNode(dialoginfor.check_time);
    nodes[7].appendChild(text);
    nodes[8].setAttribute("Name","SecretLevel");
    text = doc.createTextNode(dialoginfor.check_time);
    nodes[8].appendChild(text);
    nodes[9].setAttribute("Name","Remark");
    text = doc.createTextNode(dialoginfor.check_time);
    nodes[9].appendChild(text);
    nodes[10].setAttribute("Name","Reserved1");
    text = doc.createTextNode(dialoginfor.check_time);
    nodes[10].appendChild(text);
    nodes[11].setAttribute("Name","Reserved2");
    text = doc.createTextNode(dialoginfor.check_time);
    nodes[11].appendChild(text);
    nodes[12].setAttribute("Name","Reserved3");
    text = doc.createTextNode(dialoginfor.check_time);
    nodes[12].appendChild(text);
    for(int i=0;i<13;i++) {
        head.appendChild(nodes[i]);
    }
    QDomElement Schema = doc.createElement("SchemaRecord"); //信息描述结点
    root.appendChild(Schema);
//BasicInfo
    QDomElement Basic = doc.createElement("BasicInfo");
    Schema.appendChild(Basic);

    QDomElement record = doc.createElement("RecordIndex");
    Yzty::HostInfo *hostinfo = new Yzty::HostInfo();
    ToXmlelem(record, hostinfo);
    record.setAttribute("Name","HostInfo");
    Basic.appendChild(record);

    record = doc.createElement("RecordIndex");
    Yzty::AccountInfo *accountinfo = new Yzty::AccountInfo();
    ToXmlelem(record,accountinfo);
    record.setAttribute("Name","AccountInfo");
    Basic.appendChild(record);

    record = doc.createElement("RecordIndex");
    Yzty::NetWorkInfo *networkinfo = new Yzty::NetWorkInfo();
    ToXmlelem(record,networkinfo);
    record.setAttribute("Name","NetWorkInfo");
    Basic.appendChild(record);

    record = doc.createElement("RecordIndex");
    Yzty::HardDiskInfo *harddiskinfo = new Yzty::HardDiskInfo;
    ToXmlelem(record,harddiskinfo);
    record.setAttribute("Name","HardDiskInfo");
    Basic.appendChild(record);
//BasicInfo
    Basic = doc.createElement("BasicInfo");
    Schema.appendChild(Basic);

    record = doc.createElement("RecordIndex");
    Yzty::FastUSBRecord *fastusbrecord = new Yzty::FastUSBRecord();
    ToXmlelem(record, fastusbrecord);
    record.setAttribute("Name","FastUSBRecord");
    Basic.appendChild(record);

    record = doc.createElement("RecordIndex");
    Yzty::DeepUSBRecord *deepusbrecord = new Yzty::DeepUSBRecord();
    ToXmlelem(record,deepusbrecord);
    record.setAttribute("Name","DeepUSBRecord");
    Basic.appendChild(record);
//InternetRecords
    Basic = doc.createElement("InternetRecords");
    Schema.appendChild(Basic);

    record = doc.createElement("RecordIndex");
    Yzty::FastInternetRecord *fastinternetrecord = new Yzty::FastInternetRecord();
    ToXmlelem(record, fastinternetrecord);
    record.setAttribute("Name","FastInternetRecord");
    Basic.appendChild(record);

    record = doc.createElement("RecordIndex");
    Yzty::DeepInternetRecord *deepinternetrecord = new Yzty::DeepInternetRecord();
    ToXmlelem(record,deepinternetrecord);
    record.setAttribute("Name","DeepInternetRecord");
    Basic.appendChild(record);
//FileCheck
    Basic = doc.createElement("FileCheck");
    Schema.appendChild(Basic);

    record = doc.createElement("RecordIndex");
    Yzty::FastFileCheck *fastfilecheck = new Yzty::FastFileCheck();
    ToXmlelem(record, fastfilecheck);
    record.setAttribute("Name","FastFileCheck");
    Basic.appendChild(record);

    record = doc.createElement("RecordIndex");
    Yzty::DeepFileCheck *deepfilecheck = new Yzty::DeepFileCheck();
    ToXmlelem(record,deepfilecheck);
    record.setAttribute("Name","DeepFileCheck");
    Basic.appendChild(record);
//SystemSecurity
    Basic = doc.createElement("SystemSecurity");
    Schema.appendChild(Basic);

    record = doc.createElement("RecordIndex");
    Yzty::ShareFile *sharefile = new Yzty::ShareFile();
    ToXmlelem(record, sharefile);
    record.setAttribute("Name","ShareFile");
    Basic.appendChild(record);

    record = doc.createElement("RecordIndex");
    Yzty::SystemPatch *systempatch = new Yzty::SystemPatch();
    ToXmlelem(record,systempatch);
    record.setAttribute("Name","SystemPatch");
    Basic.appendChild(record);

    record = doc.createElement("RecordIndex");
    Yzty::OSInstallation *osinstallation = new Yzty::OSInstallation();
    ToXmlelem(record, osinstallation);
    record.setAttribute("Name","OSInstallation");
    Basic.appendChild(record);

    record = doc.createElement("RecordIndex");
    Yzty::Antivirus *antivirus = new Yzty::Antivirus();
    ToXmlelem(record,antivirus);
    record.setAttribute("Name","Antivirus");
    Basic.appendChild(record);

    record = doc.createElement("RecordIndex");
    Yzty::SWInstall *swinstall = new Yzty::SWInstall();
    ToXmlelem(record, swinstall);
    record.setAttribute("Name","SWInstall");
    Basic.appendChild(record);

    record = doc.createElement("RecordIndex");
    Yzty::SpecialDefense *specialdefense = new Yzty::SpecialDefense();
    ToXmlelem(record,specialdefense);
    record.setAttribute("Name","SpecialDefense");
    Basic.appendChild(record);

    record = doc.createElement("RecordIndex");
    Yzty::WirelessDevice *wirelessdevice = new Yzty::WirelessDevice();
    ToXmlelem(record,wirelessdevice);
    record.setAttribute("Name","WirelessDevice");
    Basic.appendChild(record);

    record = doc.createElement("RecordIndex");
    Yzty::VirtualMachine *virtualmachine = new Yzty::VirtualMachine();
    ToXmlelem(record,virtualmachine);
    record.setAttribute("Name","VirtualMachine");
    Basic.appendChild(record);
//SecuritySetting
    Basic = doc.createElement("SecuritySetting");
    Schema.appendChild(Basic);

    record = doc.createElement("RecordIndex");
    Yzty::AccountStrategy *accountstrategy = new Yzty::AccountStrategy();
    ToXmlelem(record, accountstrategy);
    record.setAttribute("Name","AccountStrategy");
    Basic.appendChild(record);

    record = doc.createElement("RecordIndex");
    Yzty::AccountSetting *accountsetting = new Yzty::AccountSetting();
    ToXmlelem(record,accountsetting);
    record.setAttribute("Name","AccountSetting");
    Basic.appendChild(record);

    record = doc.createElement("RecordIndex");
    Yzty::AuditStrategy *auditstrategy = new Yzty::AuditStrategy();
    ToXmlelem(record, auditstrategy);
    record.setAttribute("Name","AuditStrategy");
    Basic.appendChild(record);

    record = doc.createElement("RecordIndex");
    Yzty::AccountPermissionSetting *accpersetting = new Yzty::AccountPermissionSetting();
    ToXmlelem(record,accpersetting);
    record.setAttribute("Name","AccountPermissionSetting");
    Basic.appendChild(record);

    record = doc.createElement("RecordIndex");
    Yzty::Services *services = new Yzty::Services();
    ToXmlelem(record, services);
    record.setAttribute("Name","Services");
    Basic.appendChild(record);

    record = doc.createElement("RecordIndex");
    Yzty::Ports *ports = new Yzty::Ports();
    ToXmlelem(record,ports);
    record.setAttribute("Name","Ports");
    Basic.appendChild(record);
//Others
    Basic = doc.createElement("Others");
    Schema.appendChild(Basic);

    record = doc.createElement("RecordIndex");
    Yzty::EmailCheck *emailcheck = new Yzty::EmailCheck();
    ToXmlelem(record, emailcheck);
    record.setAttribute("Name","EmailCheck");
    Basic.appendChild(record);

//信息
    //HostInfo
    Basic = doc.createElement("BasicInfo");
    Schema.appendChild(Basic);
    const QVector<Yzty::BaceInfor*> infors = hardinfor[(int)Yzty::HardToolCode::OsAndHost];
    if(infors.size() >= 1) {
        hostinfo->_infor[Yzty::HostInfo::OSVersion] = infors[0]->GetItem(3);
        hostinfo->_infor[Yzty::HostInfo::HostName] = QHostInfo::localHostName();
        record = doc.createElement("RecordIndex");
        hostinfo->_infor[Yzty::HostInfo::OSVersion];
        ToXmlelem(record, hostinfo,false);
        record.setAttribute("Name","HostInfo");
        Basic.appendChild(record);
    }
    //AccountInfo

    //NetWorkInfo
    const QVector<Yzty::BaceInfor*> tem_infor = normalinfor[(int)Yzty::NormalToolCode::HostInfor];
    const Yzty::HostInfor *allinfor = dynamic_cast<const Yzty::HostInfor*>(tem_infor.first());
    const QVector<Yzty::NetInfor*> net_infors=allinfor->netinfors;
    if(net_infors.size() >= 1) {
        networkinfo->_infor[Yzty::NetWorkInfo::IP] = net_infors.value(0)->_infors[(int)Yzty::NetInfor::IP].Information;
        networkinfo->_infor[Yzty::NetWorkInfo::Mac] = net_infors.value(0)->_infors[(int)Yzty::NetInfor::MAC].Information;
        record = doc.createElement("RecordIndex");
        ToXmlelem(record, networkinfo,false);
        record.setAttribute("Name","NetWorkInfo");
        Basic.appendChild(record);
    }
    //HardDiskInfo
    //FastUSBRecord
    //DeepUSBRecord
    //FastFileCheck
    QVector<Yzty::FastFileCheck*> fastfilecheckinfor;
    for(int j = 0;j<(int)Yzty::FileToolCode::NUMS;j++) {
        for(Yzty::BaceInfor* infors:fileinfor[j]) {
            Yzty::FileRecordInfor* infor = dynamic_cast<Yzty::FileRecordInfor*>(infors);
            Yzty::FastFileCheck *tem_infor = new Yzty::FastFileCheck();
            QString keys = "";
            QString informations = "";
            for(Yzty::FileKeyWordPos& temp:infor->_filerecord->_key_pos){
                QString key=KeyWordLib::GetInstance()->GetWord(temp._lib_id,int(temp._keyword_id));
                QString information = QString("位置: %1行-%2列-%3页").arg(temp._row).arg(temp._col).arg(temp._page);
                keys.append(key + "  ");
                informations.append(information + "  ");
            }
            tem_infor->_infor[Yzty::FastFileCheck::FileName] = infor->_filetname;
            tem_infor->_infor[Yzty::FastFileCheck::FilePath] = infor->_filepath;
            tem_infor->_infor[Yzty::FastFileCheck::FileSize] = infor->_filesize;
            tem_infor->_infor[Yzty::FastFileCheck::ModifyDate] = infor->_lastmodifytime;
            tem_infor->_infor[Yzty::FastFileCheck::CreateDate] = infor->_createtime;
            tem_infor->_infor[Yzty::FastFileCheck::KeywordHit] = keys;
            tem_infor->_infor[Yzty::FastFileCheck::KeyAbstract] = informations;
            tem_infor->_infor[Yzty::FastFileCheck::Application] = "";
            tem_infor->_infor[Yzty::FastFileCheck::Deduction] = "";
            tem_infor->_infor[Yzty::FastFileCheck::JudgedMan] = infor->_evaluator;
            tem_infor->_infor[Yzty::FastFileCheck::JudgedRemark] = infor->_descripe;
            tem_infor->_infor[Yzty::FastFileCheck::Level] = infor->_pwlevel;
            fastfilecheckinfor.push_back(tem_infor);
        }
    }
    Basic = doc.createElement("BasicInfo");
    Schema.appendChild(Basic);
    QDomElement records = doc.createElement("RecordIndex");
    for(Yzty::FastFileCheck* infor:fastfilecheckinfor) {

        record = doc.createElement("Record");
        ToXmlelem(record, infor,false);
        records.appendChild(record);
    }
    records.setAttribute("Name","HostInfo");
    Basic.appendChild(records);

    //DeepFileCheck
    //ShareFile
    QVector<Yzty::ShareFile*> shareinfors;
    QVector<Yzty::BaceInfor*>&_infors = securityinfor[0];
    for(const Yzty::BaceInfor* infor:_infors) {
        const Yzty::SysShareDirInfor* temp=dynamic_cast<const Yzty::SysShareDirInfor*>(infor);
        Yzty::ShareFile *tem_infor = new Yzty::ShareFile();
        tem_infor->_infor[Yzty::ShareFile::Name] = temp->_infors[Yzty::SysShareDirInfor::SHARENAME];
        tem_infor->_infor[Yzty::ShareFile::Path] = temp->_infors[Yzty::SysShareDirInfor::ROUTE];
        tem_infor->_infor[Yzty::ShareFile::Authority] = temp->_infors[Yzty::SysShareDirInfor::PERM];
        tem_infor->_infor[Yzty::ShareFile::Deduction] = "";
        shareinfors.push_back(tem_infor);
    }
    Basic = doc.createElement("BasicInfo");
    Schema.appendChild(Basic);
    records = doc.createElement("RecordIndex");
    for(Yzty::ShareFile* infor:shareinfors) {

        record = doc.createElement("Record");
        ToXmlelem(record, infor,false);
        records.appendChild(record);
    }
    records.setAttribute("Name","ShareFile");
    Basic.appendChild(records);

    //SystemPatch
    QVector<Yzty::SystemPatch*> systempatchs;
    _infors = securityinfor[(int)Yzty::SecurityToolCode::SysUpdate];
    for(const Yzty::BaceInfor* infor:_infors) {
        const Yzty::SysUpdateInfor* temp=dynamic_cast<const Yzty::SysUpdateInfor*>(infor);
        Yzty::SystemPatch *tem_infor = new Yzty::SystemPatch();
        tem_infor->_infor[Yzty::SystemPatch::ID] = "";
        tem_infor->_infor[Yzty::SystemPatch::Description] = temp->_infors[Yzty::SysUpdateInfor::UPDATENAME];
        tem_infor->_infor[Yzty::SystemPatch::VulDescription] = temp->_infors[Yzty::SysUpdateInfor::DESCRIP];
        tem_infor->_infor[Yzty::SystemPatch::Date] = temp->_infors[Yzty::SysUpdateInfor::UPDATEVER];
        tem_infor->_infor[Yzty::SystemPatch::Deduction] = "发现未安装补丁";
        systempatchs.push_back(tem_infor);
    }
    Basic = doc.createElement("BasicInfo");
    Schema.appendChild(Basic);
    records = doc.createElement("RecordIndex");
    for(Yzty::SystemPatch* infor:systempatchs) {

        record = doc.createElement("Record");
        ToXmlelem(record, infor,false);
        records.appendChild(record);
    }
    records.setAttribute("Name","SystemPatch");
    Basic.appendChild(records);
    //SWInstall
    QVector<Yzty::SWInstall*> swinstalls;
    _infors = normalinfor[(int)Yzty::NormalToolCode::SoftLists];
    for(const Yzty::BaceInfor* infor:_infors) {
        const Yzty::SystemSoftList* temp=dynamic_cast<const Yzty::SystemSoftList*>(infor);
        Yzty::SWInstall *tem_infor = new Yzty::SWInstall();
        tem_infor->_infor[Yzty::SWInstall::Name] = temp->_infors[Yzty::SystemSoftList::Name];
        tem_infor->_infor[Yzty::SWInstall::Company] = temp->_descripe;
        tem_infor->_infor[Yzty::SWInstall::InstallTime] = temp->_infors[Yzty::SystemSoftList::Time];
        swinstalls.push_back(tem_infor);
    }
    Basic = doc.createElement("BasicInfo");
    Schema.appendChild(Basic);
    records = doc.createElement("RecordIndex");
    for(Yzty::SWInstall* infor:swinstalls) {

        record = doc.createElement("Record");
        ToXmlelem(record, infor,false);
        records.appendChild(record);
    }
    records.setAttribute("Name","SWInstall");
    Basic.appendChild(records);
    //SpecialDefense
    //WirelessDevice
    QVector<Yzty::WirelessDevice*> wirelessdevices;
    _infors = hardinfor[(int)Yzty::HardToolCode::NetCard];
    for(const Yzty::BaceInfor* infor:_infors) {
        const Yzty::networkcardInfor* temp=dynamic_cast<const Yzty::networkcardInfor*>(infor);
        Yzty::WirelessDevice *tem_infor = new Yzty::WirelessDevice();
        tem_infor->_infor[Yzty::WirelessDevice::Name] = temp->_prodname;
        tem_infor->_infor[Yzty::WirelessDevice::Company] = temp->_vendorbname;
        tem_infor->_infor[Yzty::WirelessDevice::Description] = temp->_ability;
        tem_infor->_infor[Yzty::WirelessDevice::Type] = temp->_model;
        tem_infor->_infor[Yzty::WirelessDevice::Deduction] = "";
        wirelessdevices.push_back(tem_infor);
    }
    Basic = doc.createElement("BasicInfo");
    Schema.appendChild(Basic);
    records = doc.createElement("RecordIndex");
    for(Yzty::WirelessDevice* infor:wirelessdevices) {

        record = doc.createElement("Record");
        ToXmlelem(record, infor,false);
        records.appendChild(record);
    }
    records.setAttribute("Name","WirelessDevice");
    Basic.appendChild(records);
    //VirtualMachine
    //AccountStrategy
    //AccountSetting
    //AuditStrategy
    //AccountPermissionSetting
    //Services
    QVector<Yzty::Services*> servicess;
    _infors = securityinfor[(int)Yzty::SecurityToolCode::SysServers];
    for(const Yzty::BaceInfor* infor:_infors) {
        const Yzty::SysServerInfor* temp=dynamic_cast<const Yzty::SysServerInfor*>(infor);
        Yzty::Services *tem_infor = new Yzty::Services();
        tem_infor->_infor[Yzty::Services::ServiceName] = temp->_infors[Yzty::SysServerInfor::SERNAME];
        tem_infor->_infor[Yzty::Services::PID] = "";
        tem_infor->_infor[Yzty::Services::PName] = temp->_infors[Yzty::SysServerInfor::PRONAME];
        tem_infor->_infor[Yzty::Services::Description] = temp->_infors[Yzty::SysServerInfor::DESCRIPTION];
        tem_infor->_infor[Yzty::Services::Path] = temp->_infors[Yzty::SysServerInfor::PATH];
        tem_infor->_infor[Yzty::Services::Status] = temp->_infors[Yzty::SysServerInfor::STATE];
        tem_infor->_infor[Yzty::Services::Signature] = temp->_infors[Yzty::SysServerInfor::SIGN];
        tem_infor->_infor[Yzty::Services::Auto] = temp->_infors[Yzty::SysServerInfor::STARTTYPE];
        tem_infor->_infor[Yzty::Services::Deduction] = "";
        servicess.push_back(tem_infor);
    }
    Basic = doc.createElement("BasicInfo");
    Schema.appendChild(Basic);
    records = doc.createElement("RecordIndex");
    for(Yzty::Services* infor:servicess) {

        record = doc.createElement("Record");
        ToXmlelem(record, infor,false);
        records.appendChild(record);
    }
    records.setAttribute("Name","Services");
    Basic.appendChild(records);
    //Ports
    QVector<Yzty::Ports*> portss;
    _infors = securityinfor[(int)Yzty::SecurityToolCode::NetPortInfor];
    for(const Yzty::BaceInfor* infor:_infors) {
        const Yzty::NetPortInfor* temp=dynamic_cast<const Yzty::NetPortInfor*>(infor);
        Yzty::Ports *tem_infor = new Yzty::Ports();
        tem_infor->_infor[Yzty::Ports::Port] = temp->_infors[Yzty::NetPortInfor::LOCALPORT];
        tem_infor->_infor[Yzty::Ports::Protocol] = temp->_infors[Yzty::NetPortInfor::PROTO];;
        tem_infor->_infor[Yzty::Ports::LocalIP] = temp->_infors[Yzty::NetPortInfor::LOCALIP];
        tem_infor->_infor[Yzty::Ports::RemoteIP] = temp->_infors[Yzty::NetPortInfor::FOREIGNIP];
        tem_infor->_infor[Yzty::Ports::Status] = temp->_infors[Yzty::NetPortInfor::PORTSTATE];
        tem_infor->_infor[Yzty::Ports::PID] = temp->_infors[Yzty::NetPortInfor::PID];
        tem_infor->_infor[Yzty::Ports::PName] = temp->_infors[Yzty::NetPortInfor::PNAME];
        tem_infor->_infor[Yzty::Ports::Deduction] = "";
        portss.push_back(tem_infor);
    }
    Basic = doc.createElement("BasicInfo");
    Schema.appendChild(Basic);
    records = doc.createElement("RecordIndex");
    for(Yzty::Ports* infor:portss) {

        record = doc.createElement("Record");
        ToXmlelem(record, infor,false);
        records.appendChild(record);
    }
    records.setAttribute("Name","Ports");
    Basic.appendChild(records);
    //Email


    QFile file("../cache/tempreport/xmlreport.xml");
    if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
        return false;
    QTextStream out(&file);
    out.setCodec("UTF-8");
    doc.save(out, 4, QDomNode::EncodingFromTextStream);
    file.close();
      return true;
}

void ReportTool::getgenfilehtml() { //文件总体报告
    QFile file("../cache/tempreport/file_genreport.html");
    file.open(QIODevice::WriteOnly | QIODevice::Text);//文件打开
    QTextStream out(&file);
    int i =1; //序号
    out << QString("<!DOCTYPE html>")<< endl;
    out << QString("<html lang=\"en\">") << endl;
    out << QString("<head>\n\t<meta charset=\"UTF-8\">\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n\t<title>Document</title></head>\n");
    out << QString("<style>table{ table-layout:fixed; } td{border: 1px solid black; border-width: 0 1px  1px 0; padding: 0 5px; font-size: 14px; word-wrap: break-word; }</style>");
    out << QString("<body>")<<endl;
    out << QString("<div style=\"margin:0 auto;padding: 0; width: 1000px;\">")<<endl;
    out << QString("<h1 style=\"text-align: center;\">文件总体报告</h1>");
    out << QString("\t<div class=\"headd\">检查日期：%1</div>").arg(dialoginfor.check_time)<<endl;
    out << QString("\t\t<table border=\"1px\" rules=\"all\" width=\"1000px\">")<< endl;
    out << "\t\t\t" <<Tohtmlelem("检查单位",dialoginfor.check_unit,"检查人员",dialoginfor.check_peo)<<endl;
    out << "\t\t\t" <<Tohtmlelem("被检单位",dialoginfor.be_check_unit,"被检部门",dialoginfor.be_check_sec)<<endl;
    out << "\t\t\t" <<Tohtmlelem("主机责任人",dialoginfor.be_check_peo,"主机密级",dialoginfor.levelpc)<<endl;
    out << "\t\t\t" <<QString("<tr><td>行政区域</td><td colspan=\"3\">%1</td></tr>").arg(dialoginfor.region)<<endl;
    out << "\t\t\t" <<Tohtmlelem("主机型号",dialoginfor.host_model,"主机名称",dialoginfor.host_name)<<endl;
    out << "\t\t\t" <<Tohtmlelem("CPU",dialoginfor.cpu,"操作系统",dialoginfor.os)<<endl;
    out << "\t\t\t" <<Tohtmlelem("主硬盘号",dialoginfor.mainharddisk,"IP地址",dialoginfor.ip)<<endl;
    out << "\t\t\t" <<Tohtmlelem("违规存储",dialoginfor.irrgular_storage,"合规存储",dialoginfor.standard_storage)<<endl;
    out << "\t\t\t" <<Tohtmlelem("检查路径",dialoginfor.filecheckpath,"检查文件数",dialoginfor.filechecknum)<<endl;
    out << "\t\t\t" <<QString("<tr><td>判定结果</td><td colspan=\"3\">%1</td></tr>").arg(dialoginfor.determine_result)<<endl;
    out << "</table>" << endl;
    out << QString("\t\t<table border=\"1px\" rules=\"all\" width=\"1000px\">")<< endl;

    out << Tohtmlelem({"序号","文件名称","文件密级","判定结果"},{1,1,1,1});
//    for(Yzty::BaceInfor* infors:fileinfor1) {
//        Yzty::FileRecordInfor* infor = dynamic_cast<Yzty::FileRecordInfor*>(infors);

//        out << Tohtmlelem({QString::number(i++),infor->_filetname,infor->_pwlevel,infor->_result},{1,1,1,1});
//    }

    for(int j = 0;j<(int)Yzty::FileToolCode::NUMS;j++) {
        for(Yzty::BaceInfor* infors:fileinfor[j]) {
            Yzty::FileRecordInfor* infor = dynamic_cast<Yzty::FileRecordInfor*>(infors);
            out << Tohtmlelem({QString::number(i++),infor->_filetname,infor->_pwlevel,infor->_result},{1,1,1,1});
        }
    }
    out << "</table>" << endl;
    out << QString("\t\t</table>\n\t</div>\n</body>\n</html>");
    file.close();
}

void ReportTool::getfilehtml() {                   //文件详细检查报告
    int i = 1;//序号

//    Yzty::FileRecordInfor* infor = dynamic_cast<Yzty::FileRecordInfor*>(fileinfor1[0]);
//    std::cout << "文件名字测试"  << std::endl;
//    std::cout << infor->_filetname.toStdString() << std::endl;

    QFile file("../cache/tempreport/file_detailedreport.html");
    file.open(QIODevice::WriteOnly | QIODevice::Text);//文件打开
    QTextStream out(&file);
    out << QString("<!DOCTYPE html>")<< endl;
    out << QString("<html lang=\"en\">") << endl;
    out << QString("<head>\n\t<meta charset=\"UTF-8\">\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n\t<title>Document</title></head>\n");
    out << QString("<style>table{ table-layout:fixed; } td{border: 1px solid black; border-width: 0 1px  1px 0; padding: 0 5px; font-size: 14px; word-wrap: break-word; }</style>");
    out << QString("<body>")<<endl;
    out << QString("<div style=\"margin:0 auto;padding: 0; width: 1000px;\">")<<endl;
    out << QString("<h1 style=\"text-align: center;\">文件详细报告</h1>");
    out << QString("\t<div class=\"headd\">检查日期：%1</div>").arg(dialoginfor.check_time)<<endl;
    out << QString("\t\t<table border=\"1px\" rules=\"all\" width=\"1000px\">")<< endl;
    out << "\t\t\t" <<Tohtmlelem("检查单位",dialoginfor.check_unit,"检查人员",dialoginfor.check_peo)<<endl;
    out << "\t\t\t" <<Tohtmlelem("被检单位",dialoginfor.be_check_unit,"被检部门",dialoginfor.be_check_sec)<<endl;
    out << "\t\t\t" <<Tohtmlelem("主机责任人",dialoginfor.be_check_peo,"主机密级",dialoginfor.levelpc)<<endl;
    out << "\t\t\t" <<QString("<tr><td>行政区域</td><td colspan=\"3\">%1</td></tr>").arg(dialoginfor.region)<<endl;
    out << "\t\t\t" <<Tohtmlelem("主机型号",dialoginfor.host_model,"主机名称",dialoginfor.host_name)<<endl;
    out << "\t\t\t" <<Tohtmlelem("CPU",dialoginfor.cpu,"操作系统",dialoginfor.os)<<endl;
    out << "\t\t\t" <<Tohtmlelem("主硬盘号",dialoginfor.mainharddisk,"IP地址",dialoginfor.ip)<<endl;
    out << "\t\t\t" <<Tohtmlelem("违规存储",dialoginfor.irrgular_storage,"合规存储",dialoginfor.standard_storage)<<endl;
    out << "\t\t\t" <<Tohtmlelem("检查路径",dialoginfor.filecheckpath,"检查文件数",dialoginfor.filechecknum)<<endl;
    out << "\t\t\t" <<QString("<tr><td>判定结果</td><td colspan=\"3\">%1</td></tr>").arg(dialoginfor.determine_result)<<endl;
    out << "</table>" << endl;
    out << QString("\t\t<table border=\"1px\" rules=\"all\" width=\"1000px\">")<< endl;
    out << Tohtmlelem({"序号","文件信息"},{1,4}) << endl;
    for(int j = 0;j<(int)Yzty::FileToolCode::NUMS;j++) {
        for(Yzty::BaceInfor* infors:fileinfor[j]) {
            Yzty::FileRecordInfor* infor = dynamic_cast<Yzty::FileRecordInfor*>(infors);

            out << Tohtmlelem({QString::number(i++),"文件密级",infor->_pwlevel,"判定结果",infor->_result},{5,1,1,1,1}, true);
            out << Tohtmlelem({"文件名称",infor->_filetname},{1,3});
            out << Tohtmlelem({"存储路径",infor->_filepath},{1,3});
            QString keys = "";
            QString informations = "";
            for(Yzty::FileKeyWordPos& temp:infor->_filerecord->_key_pos){
                QString key=KeyWordLib::GetInstance()->GetWord(temp._lib_id,int(temp._keyword_id));
                QString information = QString("位置: %1行-%2列-%3页").arg(temp._row).arg(temp._col).arg(temp._page);
                keys.append(key + "  ");
                informations.append(information + "  ");
            }
            out << Tohtmlelem({"命中关键词",keys},{1,3});
            out << Tohtmlelem({"摘要信息",informations},{1,3});
        }
    }
    out << "</table>" << endl;
    out << QString("\t\t</table>\n\t</div>\n</body>\n</html>");
    file.close();
}


bool ReportTool::getgenhtml()//获取总体检查报告html
{
    QFile file("../cache/tempreport/genreport.html");
    file.open(QIODevice::WriteOnly | QIODevice::Text);//文件打开
    QTextStream out(&file);
    out << QString("<!DOCTYPE html>")<< endl;
    out << QString("<html lang=\"en\">") << endl;
    out << QString("<head>\n\t<meta charset=\"UTF-8\">\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n\t<title>Document</title></head>\n");
    out << QString("<body>")<<endl;
    out << QString("<div style=\"margin:0 auto;padding: 0; width: 1000px;\">")<<endl;
    out << QString("<h1 style=\"text-align: center;\">总体检查报告</h1>");
    out << QString("\t<div class=\"headd\">检查日期：%1</div>").arg(dialoginfor.check_time)<<endl;
    out << QString("\t\t<table border=\"1px\" rules=\"all\" width=\"1000px\">")<< endl;
    out << "\t\t\t" <<Tohtmlelem("检查单位",dialoginfor.check_unit,"检查人员",dialoginfor.check_peo)<<endl;
    out << "\t\t\t" <<Tohtmlelem("被检单位",dialoginfor.be_check_unit,"被检部门",dialoginfor.be_check_sec)<<endl;
    out << "\t\t\t" <<Tohtmlelem("主机责任人",dialoginfor.be_check_peo,"主机密级",dialoginfor.levelpc)<<endl;
    out << "\t\t\t" <<QString("<tr><td>行政区域</td><td colspan=\"3\">%1</td></tr>").arg(dialoginfor.region)<<endl;
    out << "\t\t\t" <<Tohtmlelem("主机型号",dialoginfor.host_model,"主机名称",dialoginfor.host_name)<<endl;
    out << "\t\t\t" <<Tohtmlelem("CPU",dialoginfor.cpu,"操作系统",dialoginfor.os)<<endl;
    out << "\t\t\t" <<Tohtmlelem("主硬盘号",dialoginfor.mainharddisk,"IP地址",dialoginfor.ip)<<endl;
    out << "\t\t\t" <<Tohtmlelem("违规存储",dialoginfor.irrgular_storage,"合规存储",dialoginfor.standard_storage)<<endl;
    out << "\t\t\t" <<QString("<tr><td>判定结果</td><td colspan=\"3\">%1</td></tr>").arg(dialoginfor.determine_result)<<endl;
    out << "\t\t\t" <<Tohtmlelem("序号","检查项目","结果描述","检查结果")<<endl;
    out << "\t\t\t" << QString("<tr><td colspan=\"4\">一、终端基本信息</td></tr>") << endl;
    for(int i=0;i<10;i++)
    {
        out << "\t\t\t" << Tohtmlelem(QString::number(i+1),generalreport.item[i].CheckItem,generalreport.item[i].Description,generalreport.item[i].CheckResult) << endl;
    }
    out << "\t\t\t" << QString("<tr><td colspan=\"4\">二、USB设备检查</td></tr>") << endl;
    for(int i=10;i<14;i++)
    {
        out << "\t\t\t" << Tohtmlelem(QString::number(i+1),generalreport.item[i].CheckItem,generalreport.item[i].Description,generalreport.item[i].CheckResult) << endl;
    }
    out << "\t\t\t" << QString("<tr><td colspan=\"4\">三、违规联网记录</td></tr>") << endl;
    for(int i=14;i<18;i++)
    {
        out << "\t\t\t" << Tohtmlelem(QString::number(i+1),generalreport.item[i].CheckItem,generalreport.item[i].Description,generalreport.item[i].CheckResult) << endl;
    }
    out << "\t\t\t" << QString("<tr><td colspan=\"4\">四、终端软件检查</td></tr>") << endl;
    for(int i=18;i<19;i++)
    {
        out << "\t\t\t" << Tohtmlelem(QString::number(i+1),generalreport.item[i].CheckItem,generalreport.item[i].Description,generalreport.item[i].CheckResult) << endl;
    }
    out << "\t\t\t" << QString("<tr><td colspan=\"4\">五、系统安全信息</td></tr>") << endl;
    for(int i=19;i<22;i++)
    {
        out << "\t\t\t" << Tohtmlelem(QString::number(i+1),generalreport.item[i].CheckItem,generalreport.item[i].Description,generalreport.item[i].CheckResult) << endl;
    }
    out << "\t\t\t" << QString("<tr><td colspan=\"4\">六、文本文件检查</td></tr>") << endl;
    for(int i=22;i<27;i++)
    {
        out << "\t\t\t" << Tohtmlelem(QString::number(i+1),generalreport.item[i].CheckItem,generalreport.item[i].Description,generalreport.item[i].CheckResult) << endl;
    }
    out << "\t\t\t" << QString("<tr><td colspan=\"4\">七、图片文件检查</td></tr>") << endl;
    for(int i=27;i<(int)Yzty::GeneralReport::NUMS;i++)
    {
        out << "\t\t\t" << Tohtmlelem(QString::number(i+1),generalreport.item[i].CheckItem,generalreport.item[i].Description,generalreport.item[i].CheckResult) << endl;
    }
    out << QString("\t\t</table>\n\t</div>\n</body>\n</html>");
    file.close();
    return true;
}
void ReportTool::getdetailedhtml()
{
    int i=0;
    QFile file("../cache/tempreport/detailedreport.html");
    file.open(QIODevice::WriteOnly | QIODevice::Text);//文件打开
    QTextStream out(&file);
    out << QString("<!DOCTYPE html>")<< endl;
    out << QString("<html lang=\"en\">") << endl;
    out << QString("<head>\n\t<meta charset=\"UTF-8\">\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n\t<title>Document</title></head>\n");
    out << QString("<style>table{ table-layout:fixed; } td{border: 1px solid black; border-width: 0 1px  1px 0; padding: 0 5px; font-size: 14px; word-wrap: break-word; }</style>");
    out << QString("<body>")<<endl;
    out << QString("<div style=\"margin:0 auto;padding: 0; width: 1000px;\">")<<endl;
    out << QString("<h1 style=\"text-align: center;\">详细检查报告</h1>");
    out << QString("\t<div class=\"headd\">检查日期：%1</div>").arg(dialoginfor.check_time)<<endl;
    out << QString("\t\t<table border=\"1px\" rules=\"all\" width=\"1000px\">")<< endl;
    out << "\t\t\t" <<Tohtmlelem("检查单位",dialoginfor.check_unit,"检查人员",dialoginfor.check_peo)<<endl;
    out << "\t\t\t" <<Tohtmlelem("被检单位",dialoginfor.be_check_unit,"被检部门",dialoginfor.be_check_sec)<<endl;
    out << "\t\t\t" <<Tohtmlelem("主机责任人",dialoginfor.be_check_peo,"主机密级",dialoginfor.levelpc)<<endl;
    out << "\t\t\t" <<QString("<tr><td>行政区域</td><td colspan=\"3\">%1</td></tr>").arg(dialoginfor.region)<<endl;
    out << "\t\t\t" <<Tohtmlelem("主机型号",dialoginfor.host_model,"主机名称",dialoginfor.host_name)<<endl;
    out << "\t\t\t" <<Tohtmlelem("CPU",dialoginfor.cpu,"操作系统",dialoginfor.os)<<endl;
    out << "\t\t\t" <<Tohtmlelem("主硬盘号",dialoginfor.mainharddisk,"IP地址",dialoginfor.ip)<<endl;
    out << "\t\t\t" <<Tohtmlelem("违规存储",dialoginfor.irrgular_storage,"合规存储",dialoginfor.standard_storage)<<endl;
    out << "\t\t\t" <<QString("<tr><td>判定结果</td><td colspan=\"3\">%1</td></tr>").arg(dialoginfor.determine_result)<<endl;
    out << "</table>" << endl;
    /***终端基本信息***/
    out << QString("<h3>一、终端基本信息</h3>") << endl;
    out << QString("\t\t<table border=\"1px\" rules=\"all\" width=\"1000px\">")<< endl;
    out << "<tbody>"<<endl;
    out << Tohtmlelem({QString("检查项目:%1").arg("主机信息-计算机信息")},{8}) << endl;
    out << Tohtmlelem({"项目","基本信息","序列号","检查提示"},{2,3,2,1}) << endl;
    out << Tohtmlelem({"电脑型号",dialoginfor.host_model,"",""},{2,3,2,1}) << endl;
    out << Tohtmlelem({QString("检查项目:%1").arg("主机信息-网络信息")},{8}) << endl;
    out << Tohtmlelem({"当前MAC地址","基本信息","序列号","检查提示"},{2,3,2,1}) << endl;
    out << Tohtmlelem({"test1","test2","test3","test4"},{2,3,2,1}) << endl;
    out << Tohtmlelem({QString("检查项目:%1").arg("硬盘信息-硬盘基本信息")},{8}) << endl;
    out << Tohtmlelem({"项目","类型","厂商","型号","容量","序列号","启动次数","使用时长"},{1,1,1,1,1,1,1,1}) << endl;
    out << Tohtmlelem({"test1","test2","test3","test4","test1","test2","test3","test4"},{1,1,1,1,1,1,1,1}) << endl;
    out << Tohtmlelem({QString("检查项目:%1").arg("操作系统-当前操作系统")},{8}) << endl;
    out << Tohtmlelem({"分区","类型","检查提示"},{2,3,3}) << endl;
    out << Tohtmlelem({"系统名称",dialoginfor.os,generalreport.item[(int)Yzty::GeneralReport::basic_os].Description},{2,3,3}) << endl;
    for(int i=0;i<1;i++){//身份鉴别
        out << Tohtmlelem({QString("检查项目:身份鉴别%1").arg(i)},{8}) << endl;
        out << Tohtmlelem({"分区","类型","检查提示"},{2,3,3}) << endl;
        out << Tohtmlelem({"test1","test2","test3"},{2,3,3}) << endl;
    }
    out << Tohtmlelem({QString("检查项目: 屏幕保护-屏幕保护设置").arg(i)},{8}) << endl;
    out << Tohtmlelem({"分区","类型","检查提示"},{2,3,3}) << endl;
    out << Tohtmlelem({"test1","test2","test3"},{2,3,3}) << endl;
    out << "</tbody>"<<endl;
    out << "<tbody>"<<endl;
    out << Tohtmlelem({QString("检查项目:%1").arg("无线通讯")},{8}) << endl;
    out << Tohtmlelem({"test1","test2","test3","test4","test5","test6"},{1,1,1,2,2,1}) << endl;

    out << Tohtmlelem({"序号","设备类型","设备(硬件)厂商","	设备(硬件)名称","设备(硬件)描述","检查提示"},{1,1,1,2,2,1}) << endl;

    out << Tohtmlelem({QString("检查项目:%1").arg("音频视频")},{8}) << endl;
    out << Tohtmlelem({"序号","设备类型","设备(硬件)厂商","	设备(硬件)名称","设备(硬件)描述","检查提示"},{1,1,1,2,2,1}) << endl;
    QVector<Yzty::BaceInfor*> soundtemp = hardinfor[(int)Yzty::HardToolCode::SoundCard];
    i=0;
    for(const Yzty::BaceInfor* temp:soundtemp){
        const Yzty::soundcardInfor* infor=dynamic_cast<const Yzty::soundcardInfor*>(temp);
    out << Tohtmlelem({QString::number(++i),infor->_model,infor->_vendorname,infor->_probname,infor->_ability,"test6"},{1,1,1,2,2,1}) << endl;
    }
    out << "</tbody>"<<endl;
    out << "</table>" << endl;
    /***USB设备检查***/
    out << QString("<h3>二、USB设备检查</h3>") << endl;
    out << QString("\t\t<table border=\"1px\" rules=\"all\" width=\"1000px\">")<< endl;
    out << Tohtmlelem({"检查项目：手机插拔记录"},{9}) << endl;
    out << Tohtmlelem({"序号","设备类型","设备厂商","设备名称","序列号","设备VID","产品PID","首次使用时间","末次使用时间"},{1,1,1,1,1,1,1,1,1}) << endl;
    out << Tohtmlelem({"test1","test2","test2","test2","test2","test2","test2","test2test2","test2"},{1,1,1,1,1,1,1,1,1}) << endl;
    out << Tohtmlelem({"检查项目：无线蓝牙红外"},{9}) << endl;
    out << Tohtmlelem({"序号","设备类型","设备厂商","设备名称","序列号","设备VID","产品PID","首次使用时间","末次使用时间"},{1,1,1,1,1,1,1,1,1}) << endl;
    QVector<Yzty::BaceInfor*>bluetemp = hardinfor[(int)Yzty::HardToolCode::BlueTooth];
    i=1;
    for(const Yzty::BaceInfor* temp:bluetemp) {
        const Yzty::bluetoothInfor* infor = dynamic_cast<const Yzty::bluetoothInfor *>(temp);
        out << Tohtmlelem({QString::number(i++),infor->_hwclass,infor->_vendorname,infor->_prodname,"?","?","?","?","本地时间"},{1,1,1,1,1,1,1,1,1}) << endl;
    }
    out << Tohtmlelem({"检查项目：其他USB设备"},{9}) << endl;
    out << Tohtmlelem({"序号","设备类型","设备厂商","设备名称","序列号","设备VID","产品PID","首次使用时间","末次使用时间"},{1,1,1,1,1,1,1,1,1}) << endl;
    QVector<Yzty::BaceInfor*>otherusb = hardinfor[(int)Yzty::HardToolCode::KeyBoard];
    i=1;
    for(const Yzty::BaceInfor* temp:otherusb) {
        const Yzty::keyboardInfor* infor = dynamic_cast<const Yzty::keyboardInfor *>(temp);
        out << Tohtmlelem({QString::number(i++),infor->_hwclass,infor->_vendorname,infor->_probname,"?","?","?","?","本地时间"},{1,1,1,1,1,1,1,1,1}) << endl;
    }
    otherusb=hardinfor[(int)Yzty::HardToolCode::Mouse];
    for(const Yzty::BaceInfor* temp:otherusb) {
        const Yzty::mouseInfor* infor = dynamic_cast<const Yzty::mouseInfor *>(temp);
        out << Tohtmlelem({QString::number(i++),infor->_hwclass,infor->_vendorname,infor->_probname,"?","?","?","?","本地时间"},{1,1,1,1,1,1,1,1,1}) << endl;
    }
    otherusb=hardinfor[(int)Yzty::HardToolCode::Battery];
    for(const Yzty::BaceInfor* temp:otherusb) {
        const Yzty::batteryInfor* infor = dynamic_cast<const Yzty::batteryInfor *>(temp);
        out << Tohtmlelem({QString::number(i++),"电池",infor->_vendorname,infor->_probname,"?","?","?","?","本地时间"},{1,1,1,1,1,1,1,1,1}) << endl;
    }
    out << QString("</table>");
    out << QString("<h3>三、联网记录检查</h3>") << endl;
    i=1;
    out << QString("\t\t<table border=\"1px\" rules=\"all\" width=\"1000px\">")<< endl;
    QVector<Yzty::BaceInfor*>brotemp = securityinfor[(int)Yzty::SecurityToolCode::BroHistory];
    out << Tohtmlelem({"检查项目：浏览器记录"},{10}) << endl;
    out << Tohtmlelem({"序号","标题","网址","上网时间","浏览器","检查提示"},{1,2,3,2,1,1});
    for(const Yzty::BaceInfor* temp:brotemp) {
        const Yzty::WebHistoryInfor* infor = dynamic_cast<const Yzty::WebHistoryInfor *>(temp);
        QString time=QDateTime::fromSecsSinceEpoch(infor->_infors[Yzty::WebHistoryInfor::LOGTIME].toLongLong()/1000000  - 11644473600).toString("yyyy-MM-dd hh:mm:ss");
        QString TITIE = infor->_infors[Yzty::WebHistoryInfor::TITLE];
        TITIE.replace("<td>","&lttd>"); // 防止标题中出现<td>表格异常
        out << Tohtmlelem({QString::number(i++),TITIE,infor->_infors[Yzty::WebHistoryInfor::URL],time,"?","?"},{1,2,3,2,1,1}) << endl;
    }
    i=1;
    QVector<Yzty::BaceInfor*>cooktemp = securityinfor[(int)Yzty::SecurityToolCode::BroCookies];
    out << Tohtmlelem({"检查项目：Cookies记录"},{10}) << endl;
    out << Tohtmlelem({"序号","网址","上网时间","浏览器","检查提示"},{1,4,2,1,2});
    for(const Yzty::BaceInfor* temp:cooktemp) {
        const Yzty::WebCookiesInfor* infor = dynamic_cast<const Yzty::WebCookiesInfor *>(temp);
        QString URL = infor->_infors[Yzty::WebHistoryInfor::URL];
        URL.replace("<td>","&lttd>"); // 防止标题中出现<td>表格异常
        QString time=QDateTime::fromSecsSinceEpoch(infor->_infors[Yzty::WebCookiesInfor::TIME].toLongLong()/1000000  - 11644473600).toString("yyyy-MM-dd hh:mm:ss");
        out << Tohtmlelem({QString::number(i++),infor->_infors[Yzty::WebCookiesInfor::URL],time,"?","?"},{1,4,2,1,2}) << endl;
    }
    out << QString("</table>");
    out << QString("<h3>四、终端软件检查</h3>") << endl;
    out << QString("\t\t<table border=\"1px\" rules=\"all\" width=\"1000px\">")<< endl;
    out << Tohtmlelem({"检查项目：系统安装软件"},{11});
    out << Tohtmlelem({"序号","软件名称","软件版本","安装路径","安装时间","软件大小","使用频率","检查提示"},{1,2,2,2,1,1,1,1});
    QVector<Yzty::BaceInfor*> syssoft = normalinfor[(int)Yzty::NormalToolCode::SoftLists];
    i=1;
    for(const Yzty::BaceInfor* temp:syssoft) {
        const Yzty::SystemSoftList* infor = dynamic_cast<const Yzty::SystemSoftList *>(temp);
        out << Tohtmlelem({QString::number(i++),infor->_infors[Yzty::SystemSoftList::Name],infor->_infors[Yzty::SystemSoftList::Version],infor->_infors[Yzty::SystemSoftList::Version],infor->_infors[Yzty::SystemSoftList::Time],"软件大小","使用频率","?"},{1,2,2,2,1,1,1,1});
    }
    out << QString("</table>");
    out << QString("<h3>五、系统安全检查</h3>") << endl;
    out << QString("\t\t<table border=\"1px\" rules=\"all\" width=\"1000px\">")<< endl;
    out << Tohtmlelem({"检查项目：系统安装软件"},{9});
    i=1;
    QVector<Yzty::BaceInfor*>netlogin = securityinfor[(int)Yzty::SecurityToolCode::NetLogin];
    out << Tohtmlelem({"序号","远程登陆策略","策略状态","检查提示"},{1,3,2,3});
    for(const Yzty::BaceInfor* temp:netlogin) {
        const Yzty::NetLoginInfor* infor = dynamic_cast<const Yzty::NetLoginInfor *>(temp);
        out << Tohtmlelem({QString::number(i++),infor->_infors[Yzty::NetLoginInfor::FORLOGIN],infor->_infors[Yzty::NetLoginInfor::STATE],infor->_infors[Yzty::NetLoginInfor::DECISION]},{1,3,2,3});
    }
    out << Tohtmlelem({"检查项目：系统升级软件"},{9});
    i=1;
    QVector<Yzty::BaceInfor*>update = securityinfor[(int)Yzty::SecurityToolCode::SysUpdate];
    out << Tohtmlelem({"序号","升级包名称","升级包版本号","升级包描述","发布时间","检查提示"},{1,2,2,2,1,1});
    for(const Yzty::BaceInfor* temp:update) {
        const Yzty::SysUpdateInfor* infor = dynamic_cast<const Yzty::SysUpdateInfor *>(temp);
        out << Tohtmlelem({QString::number(i++),infor->_infors[Yzty::SysUpdateInfor::UPDATENAME],infor->_infors[Yzty::SysUpdateInfor::UPDATEVER],infor->_infors[Yzty::SysUpdateInfor::DESCRIP],infor->_infors[Yzty::SysUpdateInfor::PUBTIME],"?"},{1,2,2,2,1,1});
    }
    out << Tohtmlelem({"检查项目：系统开放端口"},{9});
    i=1;
    QVector<Yzty::BaceInfor*>porttemp = securityinfor[(int)Yzty::SecurityToolCode::NetPortInfor];
    QVector<QStringList> temp1;
    out << Tohtmlelem({"序号","协议","本地IP","本地端口","远程IP","远程端口","端口状态","进程名称","进程ID"},{1,1,1,1,1,1,1,1,1});
    for(const Yzty::BaceInfor* temp:porttemp) {
        const Yzty::NetPortInfor* infor = dynamic_cast<const Yzty::NetPortInfor *>(temp);
        QStringList temp2;
        for(int j=0; j<Yzty::NetPortInfor::NUMS-1;j++)
            temp2.push_back(infor->_infors[j]);
        temp1.push_back(temp2);
    }
    for(QStringList inforr:temp1) {
        out << Tohtmlelem({QString::number(i++),inforr[0],inforr[1],inforr[2],inforr[3],inforr[4],inforr[5],inforr[6],inforr[7]},{1,1,1,1,1,1,1,1,1});
    }
    out << QString("</table>");
    out << QString("<h3>六、系统安全配置</h3>") << endl;
    out << QString("\t\t<table border=\"1px\" rules=\"all\" width=\"1000px\">")<< endl;
    out << Tohtmlelem({"检查项目：账户安全配置"},{7});
    i=1;
    QVector<Yzty::BaceInfor*>acconttemp = securityinfor[(int)Yzty::SecurityToolCode::AccountSec];
    out << Tohtmlelem({"序号","项目","描述","检查提示"},{1,3,2,1});
    for(const Yzty::BaceInfor* temp:acconttemp) {
        const Yzty::AccountSecInfor* infor = dynamic_cast<const Yzty::AccountSecInfor *>(temp);
        out << Tohtmlelem({QString::number(i++),infor->_infors[Yzty::AccountSecInfor::ITEMS],infor->_infors[Yzty::AccountSecInfor::DESCRIP],"?"},{1,3,2,1});
    }
    out << Tohtmlelem({"检查项目：账户安全配置"},{7});
    i=1;
    QVector<Yzty::BaceInfor*>pwdtemp = securityinfor[(int)Yzty::SecurityToolCode::PwdConfig];
    out << Tohtmlelem({"序号","项目","描述","检查提示"},{1,3,2,1});
    for(const Yzty::BaceInfor* temp:pwdtemp) {
        const Yzty::PwdConfigInfor* infor = dynamic_cast<const Yzty::PwdConfigInfor *>(temp);
        out << Tohtmlelem({QString::number(i++),infor->_infors[Yzty::PwdConfigInfor::ITEMS],infor->_infors[Yzty::PwdConfigInfor::DESCRIP],"?"},{1,3,2,1});
    }
    out << Tohtmlelem({"检查项目：网络安全配置"},{7});
    i=1;
    QVector<Yzty::BaceInfor*>netconfigtemp = securityinfor[(int)Yzty::SecurityToolCode::NetConfig];
    out << Tohtmlelem({"序号","项目","描述","检查提示"},{1,3,2,1});
    for(const Yzty::BaceInfor* temp:netconfigtemp) {
        const Yzty::NetConfig* infor = dynamic_cast<const Yzty::NetConfig *>(temp);
        out << Tohtmlelem({QString::number(i++),infor->_infors[Yzty::NetConfig::ITEMS],infor->_infors[Yzty::NetConfig::DESCRIPTION],"?"},{1,3,2,1});
    }
    out << Tohtmlelem({"检查项目：安全审计配置"},{7});
    i=1;
    QVector<Yzty::BaceInfor*>audittemp = securityinfor[(int)Yzty::SecurityToolCode::SecAudit];
    out << Tohtmlelem({"序号","项目","描述","检查提示"},{1,3,2,1});
    for(const Yzty::BaceInfor* temp:audittemp) {
        const Yzty::SecAuditInfor* infor = dynamic_cast<const Yzty::SecAuditInfor *>(temp);
        out << Tohtmlelem({QString::number(i++),infor->_infors[Yzty::SecAuditInfor::TYPE],infor->_infors[Yzty::SecAuditInfor::TACTIC],"?"},{1,3,2,1});
    }
    out << Tohtmlelem({"检查项目：sudo策略配置"},{7});
    i=1;
    QVector<Yzty::BaceInfor*>sudotemp = securityinfor[(int)Yzty::SecurityToolCode::SudoConfig];
    out << Tohtmlelem({"序号","项目","描述","检查提示"},{1,3,2,1});
    for(const Yzty::BaceInfor* temp:sudotemp) {
        const Yzty::SudoConfigInfor* infor = dynamic_cast<const Yzty::SudoConfigInfor *>(temp);
        out << Tohtmlelem({QString::number(i++),infor->_infors[Yzty::SudoConfigInfor::TACTIC],infor->_infors[Yzty::SudoConfigInfor::DESCRIPTION],"?"},{1,3,2,1});
    }
    out << Tohtmlelem({"检查项目：防火墙配置"},{7});
    i=1;
    QVector<Yzty::BaceInfor*>firetemp = securityinfor[(int)Yzty::SecurityToolCode::NetFireWall];
    out << Tohtmlelem({"序号","项目","描述","检查提示"},{1,3,2,1});
    for(const Yzty::BaceInfor* temp:firetemp) {
        const Yzty::NetFireWallInfor* infor = dynamic_cast<const Yzty::NetFireWallInfor *>(temp);
        out << Tohtmlelem({QString::number(i++),infor->_infors[Yzty::NetFireWallInfor::ITEMS],infor->_infors[Yzty::NetFireWallInfor::DESCRIPTION],"?"},{1,3,2,1});
    }
    out << QString("</table>");
    out << QString("<h3>七、系统安全信息</h3>") << endl;
    out << QString("\t\t<table border=\"1px\" rules=\"all\" width=\"1000px\">")<< endl;
    out << Tohtmlelem({"检查项目：系统进程信息"},{7});
    i=1;
    QVector<Yzty::BaceInfor*>protemp = securityinfor[(int)Yzty::SecurityToolCode::SysProcess];
    out << Tohtmlelem({"序号","进程名称","进程ID","进程路径","检查提示"},{1,2,2,1,1});
    for(const Yzty::BaceInfor* temp:protemp) {
        const Yzty::SysProcessInfor* infor = dynamic_cast<const Yzty::SysProcessInfor *>(temp);
        out << Tohtmlelem({QString::number(i++),infor->_infors[Yzty::SysProcessInfor::NAME],infor->_infors[Yzty::SysProcessInfor::PID],infor->_infors[Yzty::SysProcessInfor::PATH],"?"},{1,2,2,1,1});
    }
    out << QString("</table>");
    out << QString("<h3>八、系统其他安全</h3>") << endl;
    out << QString("\t\t<table border=\"1px\" rules=\"all\" width=\"1000px\">")<< endl;
    out << Tohtmlelem({"检查项目：邮件客户端"},{8});
    i=1;
    QVector<Yzty::BaceInfor*>emailinfor = securityinfor[(int)Yzty::SecurityToolCode::EmailInfor];
    out << Tohtmlelem({"序号","名称","软件版本","安装路径","安装时间","软件大小","使用频率","检查提示"},{1,1,1,1,1,1,1,1});
    for(const Yzty::BaceInfor* temp:emailinfor) {
        const Yzty::EmailInfor* infor = dynamic_cast<const Yzty::EmailInfor *>(temp);
        out << Tohtmlelem({QString::number(i++),infor->_infors[Yzty::EmailInfor::NAME],infor->_infors[Yzty::EmailInfor::VERSION],infor->_infors[Yzty::EmailInfor::PATH],infor->_infors[Yzty::EmailInfor::INSTALLTIME],infor->_infors[Yzty::EmailInfor::SIZE],infor->_infors[Yzty::EmailInfor::FREQUENCE],"?"},{1,1,1,1,1,1,1,1});
    }

    out << Tohtmlelem({"检查项目：杀毒软件防护"},{8});
    i=1;
    QVector<Yzty::BaceInfor*>defendinfor = securityinfor[(int)Yzty::SecurityToolCode::DefendSoft];
    out << Tohtmlelem({"序号","软件厂商","软件名称","软件版本","安装时间","更新时间","检查提示"},{1,1,2,1,1,1,1});
    for(const Yzty::BaceInfor* temp:defendinfor) {
        const Yzty::DefendSoft* infor = dynamic_cast<const Yzty::DefendSoft *>(temp);
        out << Tohtmlelem({QString::number(i++),infor->_infors[Yzty::DefendSoft::COMPANY],infor->_infors[Yzty::DefendSoft::NAME],infor->_infors[Yzty::DefendSoft::VERSION],infor->_infors[Yzty::DefendSoft::INSTALLTIME],infor->_infors[Yzty::DefendSoft::UPDATETIME],"?"},{1,1,2,1,1,1,1});
    }


    out << QString("</table>");
    out << QString("<h3>九、文件检查</h3>") << endl;
    out << QString("\t\t<table border=\"1px\" rules=\"all\" width=\"1000px\">")<< endl;
    i = 1;


    //QVector<Yzty::FileRecordInfor*> infors:filereportinfor
    out << Tohtmlelem({QString("检查项目:常规文件检查-密级关键词命中")},{7}) << endl;
    out << Tohtmlelem({"序号","文件信息"},{1,6});
    for(Yzty::FileRecordInfor* infor:filereportinfor[(int)Yzty::FileToolCode::FKEY]) {
            out << Tohtmlelem({QString::number(i++),"文件密级",infor->_pwlevel,"判定人",infor->_evaluator,"判定结果",infor->_result},{5,1,1,1,1,1,1}, true) << endl;;
            out << Tohtmlelem({"文件名称",infor->_filetname},{1,5});
            out << Tohtmlelem({"存储路径",infor->_filepath},{1,5});
            QString keys = "";
            QString informations = "";
            for(Yzty::FileKeyWordPos& temp:infor->_filerecord->_key_pos){
                QString key=KeyWordLib::GetInstance()->GetWord(temp._lib_id,int(temp._keyword_id));
                QString information = QString("位置: %1行-%2列-%3页").arg(temp._row).arg(temp._col).arg(temp._page);
                keys.append(key + "  ");
                informations.append(information + "  ");
            }
            out << Tohtmlelem({"命中关键词",keys},{1,5});
            out << Tohtmlelem({"摘要信息",informations},{1,5});
        }

    out << Tohtmlelem({QString("检查项目:图片文件检查-密级关键词命中")},{7}) << endl;
    out << Tohtmlelem({"序号","文件信息"},{1,6});
    for(Yzty::FileRecordInfor* infor:filereportinfor[(int)Yzty::FileToolCode::PKEY]) {
            out << Tohtmlelem({QString::number(i++),"文件密级",infor->_pwlevel,"判定人",infor->_evaluator,"判定结果",infor->_result},{5,1,1,1,1,1,1}, true) << endl;;
            out << Tohtmlelem({"文件名称",infor->_filetname},{1,5});
            out << Tohtmlelem({"存储路径",infor->_filepath},{1,5});
            QString keys = "";
            QString informations = "";
            for(Yzty::FileKeyWordPos& temp:infor->_filerecord->_key_pos){
                QString key=KeyWordLib::GetInstance()->GetWord(temp._lib_id,int(temp._keyword_id));
                QString information = QString("位置: %1行-%2列-%3页").arg(temp._row).arg(temp._col).arg(temp._page);
                keys.append(key + "  ");
                informations.append(information + "  ");
            }
            out << Tohtmlelem({"命中关键词",keys},{1,5});
            out << Tohtmlelem({"摘要信息",informations},{1,5});
        }


    out << QString("</table>");
    out << QString("<h3>十、文件检查辅助</h3>") << endl;
    out << QString("\t\t<table border=\"1px\" rules=\"all\" width=\"1000px\">")<< endl;
    out << QString("</table>");
    out << QString("\t\t</table>\n\t</div>\n</body>\n</html>");
    file.close();
}

void ReportTool::getgenillhtml() { //总体违规报告
    QFile file("../cache/tempreport/genillhtml.html");
    file.open(QIODevice::WriteOnly | QIODevice::Text);//文件打开
    QTextStream out(&file);
    int i =1; //序号
    out << QString("<!DOCTYPE html>")<< endl;
    out << QString("<html lang=\"en\">") << endl;
    out << QString("<head>\n\t<meta charset=\"UTF-8\">\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n\t<title>Document</title></head>\n");
    out << QString("<style>table{ table-layout:fixed; } td{border: 1px solid black; border-width: 0 1px  1px 0; padding: 0 5px; font-size: 14px; word-wrap: break-word; }</style>");
    out << QString("<body>")<<endl;
    out << QString("<div style=\"margin:0 auto;padding: 0; width: 1000px;\">")<<endl;
    out << QString("<h1 style=\"text-align: center;\">总体违规报告</h1>");
    out << QString("\t<div class=\"headd\">检查日期：%1</div>").arg(dialoginfor.check_time)<<endl;
    out << QString("\t\t<table border=\"1px\" rules=\"all\" width=\"1000px\">")<< endl;
    out << "\t\t\t" <<Tohtmlelem("检查单位",dialoginfor.check_unit,"检查人员",dialoginfor.check_peo)<<endl;
    out << "\t\t\t" <<Tohtmlelem("被检单位",dialoginfor.be_check_unit,"被检部门",dialoginfor.be_check_sec)<<endl;
    out << "\t\t\t" <<Tohtmlelem("主机责任人",dialoginfor.be_check_peo,"主机密级",dialoginfor.levelpc)<<endl;
    out << "\t\t\t" <<QString("<tr><td>行政区域</td><td colspan=\"3\">%1</td></tr>").arg(dialoginfor.region)<<endl;
    out << "\t\t\t" <<Tohtmlelem("主机型号",dialoginfor.host_model,"主机名称",dialoginfor.host_name)<<endl;
    out << "\t\t\t" <<Tohtmlelem("CPU",dialoginfor.cpu,"操作系统",dialoginfor.os)<<endl;
    out << "\t\t\t" <<Tohtmlelem("主硬盘号",dialoginfor.mainharddisk,"IP地址",dialoginfor.ip)<<endl;
    out << "\t\t\t" <<Tohtmlelem("违规存储",dialoginfor.irrgular_storage,"合规存储",dialoginfor.standard_storage)<<endl;
    out << "\t\t\t" <<QString("<tr><td>判定结果</td><td colspan=\"3\">%1</td></tr>").arg(dialoginfor.determine_result)<<endl;
    out << "</table>" << endl;
    out << QString("\t\t</table>\n\t</div>\n</body>\n</html>");
    file.close();
}


void ReportTool::getillfilehtml() { //文件违规报告
    QFile file("../cache/tempreport/file_illreport.html");
    file.open(QIODevice::WriteOnly | QIODevice::Text);//文件打开
    QTextStream out(&file);
    int i =1; //序号
    out << QString("<!DOCTYPE html>")<< endl;
    out << QString("<html lang=\"en\">") << endl;
    out << QString("<head>\n\t<meta charset=\"UTF-8\">\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n\t<title>Document</title></head>\n");
    out << QString("<style>table{ table-layout:fixed; } td{border: 1px solid black; border-width: 0 1px  1px 0; padding: 0 5px; font-size: 14px; word-wrap: break-word; }</style>");
    out << QString("<body>")<<endl;
    out << QString("<div style=\"margin:0 auto;padding: 0; width: 1000px;\">")<<endl;
    out << QString("<h1 style=\"text-align: center;\">文件违规报告</h1>");
    out << QString("\t<div class=\"headd\">检查日期：%1</div>").arg(dialoginfor.check_time)<<endl;
    out << QString("\t\t<table border=\"1px\" rules=\"all\" width=\"1000px\">")<< endl;
    out << "\t\t\t" <<Tohtmlelem("检查单位",dialoginfor.check_unit,"检查人员",dialoginfor.check_peo)<<endl;
    out << "\t\t\t" <<Tohtmlelem("被检单位",dialoginfor.be_check_unit,"被检部门",dialoginfor.be_check_sec)<<endl;
    out << "\t\t\t" <<Tohtmlelem("主机责任人",dialoginfor.be_check_peo,"主机密级",dialoginfor.levelpc)<<endl;
    out << "\t\t\t" <<QString("<tr><td>行政区域</td><td colspan=\"3\">%1</td></tr>").arg(dialoginfor.region)<<endl;
    out << "\t\t\t" <<Tohtmlelem("主机型号",dialoginfor.host_model,"主机名称",dialoginfor.host_name)<<endl;
    out << "\t\t\t" <<Tohtmlelem("CPU",dialoginfor.cpu,"操作系统",dialoginfor.os)<<endl;
    out << "\t\t\t" <<Tohtmlelem("主硬盘号",dialoginfor.mainharddisk,"IP地址",dialoginfor.ip)<<endl;
    out << "\t\t\t" <<Tohtmlelem("违规存储",dialoginfor.irrgular_storage,"合规存储",dialoginfor.standard_storage)<<endl;
    out << "\t\t\t" <<Tohtmlelem("检查路径",dialoginfor.filecheckpath,"检查文件数",dialoginfor.filechecknum)<<endl;

    out << "\t\t\t" <<QString("<tr><td>判定结果</td><td colspan=\"3\">%1</td></tr>").arg(dialoginfor.determine_result)<<endl;
    out << "</table>" << endl;

    out << QString("\t\t<table border=\"1px\" rules=\"all\" width=\"1000px\">")<< endl;
    out << Tohtmlelem({"序号","文件信息"},{1,4}) << endl;
    for(int j = 0;j<(int)Yzty::FileToolCode::NUMS;j++) {
        if( j == (int)Yzty::FileToolCode::FILLEGAL || j == (int)Yzty::FileToolCode::PILLEGAL)
        {
            for(Yzty::BaceInfor* infors:fileinfor[j]) {
                Yzty::FileRecordInfor* infor = dynamic_cast<Yzty::FileRecordInfor*>(infors);

                out << Tohtmlelem({QString::number(i++),"文件密级",infor->_pwlevel,"判定结果",infor->_result},{5,1,1,1,1}, true);
                out << Tohtmlelem({"文件名称",infor->_filetname},{1,3});
                out << Tohtmlelem({"存储路径",infor->_filepath},{1,3});
                QString keys = "";
                QString informations = "";
                for(Yzty::FileKeyWordPos& temp:infor->_filerecord->_key_pos){
                    QString key=KeyWordLib::GetInstance()->GetWord(temp._lib_id,int(temp._keyword_id));
                    QString information = QString("位置: %1行-%2列-%3页").arg(temp._row).arg(temp._col).arg(temp._page);
                    keys.append(key + "  ");
                    informations.append(information + "  ");
                }
                out << Tohtmlelem({"命中关键词",keys},{1,3});
                out << Tohtmlelem({"摘要信息",informations},{1,3});
            }
        }
    }
    out << QString("\t\t</table>\n\t</div>\n</body>\n</html>");
    file.close();
}

void ReportTool::getdetaileddata()
{

}
void ReportTool::getgenreportdata()
{
    int sum = 0;


    if(hardinfor.size() > (int)Yzty::HardToolCode::OsAndHost) {
        if(hardinfor[(int)Yzty::HardToolCode::OsAndHost].size()==1){
            generalreport.item[Yzty::GeneralReport::basic_os].Description = "未安装多操作系统";
            generalreport.item[Yzty::GeneralReport::basic_os].CheckResult = "合格";
        }
        else{
            generalreport.item[Yzty::GeneralReport::basic_os].Description = QString("安装了%1个操作系统").arg(hardinfor[(int)Yzty::HardToolCode::OsAndHost].size()) ;
            generalreport.item[Yzty::GeneralReport::basic_os].CheckResult = "不合格";
        }
    }
    if(1){
        generalreport.item[Yzty::GeneralReport::basic_reinstall].Description="未发现15天内重装操作系统";
        generalreport.item[Yzty::GeneralReport::basic_reinstall].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::basic_reinstall].Description="";
        generalreport.item[Yzty::GeneralReport::basic_reinstall].CheckResult="不合格";
    }
    if(1){
        generalreport.item[Yzty::GeneralReport::basic_harddisk].Description="未发现硬盘最近更换";
        generalreport.item[Yzty::GeneralReport::basic_harddisk].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::basic_harddisk].Description="";
        generalreport.item[Yzty::GeneralReport::basic_harddisk].CheckResult="不合格";
    }
    if(1){
        generalreport.item[Yzty::GeneralReport::basic_partition].Description="未发现加密隐藏分区";
        generalreport.item[Yzty::GeneralReport::basic_partition].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::basic_partition].Description="";
        generalreport.item[Yzty::GeneralReport::basic_partition].CheckResult="不合格";
    }
    if(1){
        generalreport.item[Yzty::GeneralReport::basic_poweronpwd].Description="开机密码设置符合当前计算机密级要求";
        generalreport.item[Yzty::GeneralReport::basic_poweronpwd].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::basic_poweronpwd].Description="";
        generalreport.item[Yzty::GeneralReport::basic_poweronpwd].CheckResult="不合格";
    }
    if(hardinfor[(int)Yzty::HardToolCode::GraphCard].size()>=1){
        generalreport.item[Yzty::GeneralReport::basic_screensaver].Description="发现屏幕保护设置";
        generalreport.item[Yzty::GeneralReport::net_favorite].CheckResult="不合格";
        generalreport.item[Yzty::GeneralReport::basic_screensaver].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::basic_screensaver].Description="";
        generalreport.item[Yzty::GeneralReport::basic_screensaver].CheckResult="不合格";
    }
    if(1){
        generalreport.item[Yzty::GeneralReport::basic_command].Description="口令设置符合当前计算机的密级要求";
        generalreport.item[Yzty::GeneralReport::basic_command].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::basic_command].Description="";
        generalreport.item[Yzty::GeneralReport::basic_command].CheckResult="不合格";
    }
    if(1){
        generalreport.item[Yzty::GeneralReport::basic_macadd].Description="未发现MAC地址修改";
        generalreport.item[Yzty::GeneralReport::basic_macadd].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::basic_macadd].Description="";
        generalreport.item[Yzty::GeneralReport::basic_macadd].CheckResult="不合格";
    }
    if(hardinfor[(int)Yzty::HardToolCode::NetCard].size()>0){
        generalreport.item[Yzty::GeneralReport::basic_wirelesscom].Description=QString("发现无线网卡，蓝牙");
        generalreport.item[Yzty::GeneralReport::basic_wirelesscom].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::basic_wirelesscom].Description="";
        generalreport.item[Yzty::GeneralReport::basic_wirelesscom].CheckResult="不合格";
    }
    if(hardinfor.size() > (int)Yzty::HardToolCode::SoundCard){
        if(1){
            generalreport.item[Yzty::GeneralReport::basic_audiovideo].Description=QString("发现了%1个音视频设备").arg(hardinfor[(int)Yzty::HardToolCode::SoundCard].size());
            generalreport.item[Yzty::GeneralReport::basic_audiovideo].CheckResult="合格";
        }
        else{
            generalreport.item[Yzty::GeneralReport::basic_audiovideo].Description="";
            generalreport.item[Yzty::GeneralReport::basic_audiovideo].CheckResult="不合格";
        }
    }
    if(1){
        generalreport.item[Yzty::GeneralReport::usb_phone].Description="";
        generalreport.item[Yzty::GeneralReport::usb_phone].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::usb_phone].Description="";
        generalreport.item[Yzty::GeneralReport::usb_phone].CheckResult="不合格";
    }
    if(hardinfor.size() > (int)Yzty::HardToolCode::Memory)
        sum = hardinfor[(int)Yzty::HardToolCode::Memory].size();
    if(1){
        generalreport.item[Yzty::GeneralReport::usb_comstorage].Description=QString("发现%1条使用记录").arg(sum);
        generalreport.item[Yzty::GeneralReport::usb_comstorage].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::usb_comstorage].Description="";
        generalreport.item[Yzty::GeneralReport::usb_comstorage].CheckResult="不合格";
    }
    if(hardinfor.size() > (int)Yzty::HardToolCode::BlueTooth)
        sum = hardinfor[(int)Yzty::HardToolCode::BlueTooth].size();
    if(1){
        generalreport.item[Yzty::GeneralReport::usb_bluetooth].Description=QString("发现%1条使用记录").arg(sum);
        generalreport.item[Yzty::GeneralReport::usb_bluetooth].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::usb_bluetooth].Description="";
        generalreport.item[Yzty::GeneralReport::usb_bluetooth].CheckResult="不合格";
    }
    if(hardinfor.size() > (int)Yzty::HardToolCode::KeyBoard && hardinfor.size() > (int)Yzty::HardToolCode::Mouse && hardinfor.size() > (int)Yzty::HardToolCode::Battery) {
        sum = hardinfor[(int)Yzty::HardToolCode::KeyBoard].size();
        sum += hardinfor[(int)Yzty::HardToolCode::Mouse].size();
        sum += hardinfor[(int)Yzty::HardToolCode::Battery].size();
    }
    if(1){
        generalreport.item[Yzty::GeneralReport::usb_otherUSB].Description=QString("发现%1条使用记录").arg(sum);
        generalreport.item[Yzty::GeneralReport::usb_otherUSB].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::usb_otherUSB].Description="";
        generalreport.item[Yzty::GeneralReport::usb_otherUSB].CheckResult="不合格";
    }
    if(1){
        if(securityinfor.size() > (int)Yzty::SecurityToolCode::BroHistory){
            int temp = securityinfor[(int)Yzty::SecurityToolCode::BroHistory].size();
            generalreport.item[Yzty::GeneralReport::net_browser].Description=QString("发现%1条使用记录").arg(temp);
            generalreport.item[Yzty::GeneralReport::net_browser].CheckResult="合格";
        }
    }
    else{
        generalreport.item[Yzty::GeneralReport::net_browser].Description="";
        generalreport.item[Yzty::GeneralReport::net_browser].CheckResult="不合格";
    }
    if(1){
        generalreport.item[Yzty::GeneralReport::net_app].Description="";
        generalreport.item[Yzty::GeneralReport::net_app].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::net_app].Description="";
        generalreport.item[Yzty::GeneralReport::net_app].CheckResult="不合格";
    }
    if(securityinfor.size() > (int)Yzty::SecurityToolCode::BroCookies) {
        if(1){
            generalreport.item[Yzty::GeneralReport::net_cookies].Description=QString("发现%1条使用记录").arg(securityinfor[(int)Yzty::SecurityToolCode::BroCookies].size());
            generalreport.item[Yzty::GeneralReport::net_cookies].CheckResult="合格";
        }
        else{
            generalreport.item[Yzty::GeneralReport::net_cookies].Description="";
            generalreport.item[Yzty::GeneralReport::net_cookies].CheckResult="不合格";
        }
    }
    if(securityinfor.size() > (int)Yzty::SecurityToolCode::BroCollect) {
        if(1){
            int temp = securityinfor[(int)Yzty::SecurityToolCode::BroCollect].size();
            generalreport.item[Yzty::GeneralReport::net_favorite].Description=QString("发现%1条使用记录").arg(temp);
            generalreport.item[Yzty::GeneralReport::net_favorite].CheckResult="合格";
        }
        else{
            generalreport.item[Yzty::GeneralReport::net_favorite].Description="";
            generalreport.item[Yzty::GeneralReport::net_favorite].CheckResult="不合格";
        }
    }
    if(normalinfor.size() > (int)Yzty::NormalToolCode::SoftLists) {
        if(1){
            int temp = normalinfor[(int)Yzty::NormalToolCode::SoftLists].size();
            generalreport.item[Yzty::GeneralReport::app_systemapp].Description=QString("%1个安装软件").arg(temp);
            generalreport.item[Yzty::GeneralReport::app_systemapp].CheckResult="合格";
        }
        else{
            generalreport.item[Yzty::GeneralReport::app_systemapp].Description="";
            generalreport.item[Yzty::GeneralReport::app_systemapp].CheckResult="不合格";
        }
    }
    if(securityinfor.size() > (int)Yzty::SecurityToolCode::NetLogin && securityinfor[(int)Yzty::SecurityToolCode::NetLogin].size() > 3) {
        if((dynamic_cast<const Yzty::NetLoginInfor*>(securityinfor[(int)Yzty::SecurityToolCode::NetLogin][3])->_infors[Yzty::NetLoginInfor::STATE])==QString("否")){
            generalreport.item[Yzty::GeneralReport::sec_telnet].Description="未发现启用远程登陆";
            generalreport.item[Yzty::GeneralReport::sec_telnet].CheckResult="合格";
        }
        else{
            generalreport.item[Yzty::GeneralReport::sec_telnet].Description="发现启用远程登陆";
            generalreport.item[Yzty::GeneralReport::sec_telnet].CheckResult="不合格";
        }
    }
    if(securityinfor.size() > (int)Yzty::SecurityToolCode::SysUpdate) {
        if(securityinfor[(int)Yzty::SecurityToolCode::SysUpdate].size()==0){
            generalreport.item[Yzty::GeneralReport::sec_update].Description="未发现需要升级的系统软件";
            generalreport.item[Yzty::GeneralReport::sec_update].CheckResult="合格";
        }
        else{
            generalreport.item[Yzty::GeneralReport::sec_update].Description=QString("发现%1个系统升级文件").arg(securityinfor[(int)Yzty::SecurityToolCode::SysUpdate].size());
            generalreport.item[Yzty::GeneralReport::sec_update].CheckResult="不合格";
        }
    }
    if(securityinfor.size() > (int)Yzty::SecurityToolCode::DefendSoft) {
        if(securityinfor[(int)Yzty::SecurityToolCode::DefendSoft].size()!=0){
            QString temp = dynamic_cast<const Yzty::DefendSoft*>(securityinfor[(int)Yzty::SecurityToolCode::DefendSoft].first())->_infors[Yzty::DefendSoft::NAME];
            generalreport.item[Yzty::GeneralReport::sec_antivirus].Description=QString("安装了%1病毒防护软件").arg(temp);
            generalreport.item[Yzty::GeneralReport::sec_antivirus].CheckResult="合格";
        }
        else{
            generalreport.item[Yzty::GeneralReport::sec_antivirus].Description="未安装病毒防护软件";
            generalreport.item[Yzty::GeneralReport::sec_antivirus].CheckResult="不合格";
        }
    }
    sum = filereportinfor[(int)Yzty::FileToolCode::FKEY].size();
    sum += filereportinfor[(int)Yzty::FileToolCode::FOTHER].size();
    sum +=filereportinfor[(int)Yzty::FileToolCode::FILLEGAL].size();
    if(sum == 0){
        generalreport.item[Yzty::GeneralReport::file_keyword].Description="未发现命中文件";
        generalreport.item[Yzty::GeneralReport::file_keyword].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::file_keyword].Description=QString("发现%1个命中文件").arg(sum);
        generalreport.item[Yzty::GeneralReport::file_keyword].CheckResult="不合格";
    }
    sum = filereportinfor[(int)Yzty::FileToolCode::FDOUBT].size();
    if(sum == 0){
        generalreport.item[Yzty::GeneralReport::file_suspected].Description="未发现命中文件";
        generalreport.item[Yzty::GeneralReport::file_suspected].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::file_suspected].Description=QString("发现%1个命中文件").arg(sum);
        generalreport.item[Yzty::GeneralReport::file_suspected].CheckResult="不合格";
    }
    sum = filereportinfor[(int)Yzty::FileToolCode::FTOTAL].size();
    if(sum == 0){
        generalreport.item[Yzty::GeneralReport::file_secret].Description="未发现命中文件";
        generalreport.item[Yzty::GeneralReport::file_secret].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::file_secret].Description=QString("发现%1个命中文件").arg(sum);
        generalreport.item[Yzty::GeneralReport::file_secret].CheckResult="不合格";
    }
    sum = filereportinfor[(int)Yzty::FileToolCode::FOTHER].size();
    if(sum == 0){
        generalreport.item[Yzty::GeneralReport::file_other].Description="未发现命中文件";
        generalreport.item[Yzty::GeneralReport::file_other].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::file_other].Description=QString("发现%1个命中文件").arg(sum);
        generalreport.item[Yzty::GeneralReport::file_other].CheckResult="合格";
    }
    sum = filereportinfor[(int)Yzty::FileToolCode::FILLEGAL].size();
    if(sum == 0){
        generalreport.item[Yzty::GeneralReport::file_illegal].Description="未发现命中文件";
        generalreport.item[Yzty::GeneralReport::file_illegal].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::file_illegal].Description=QString("发现%1个命中文件").arg(sum);
        generalreport.item[Yzty::GeneralReport::file_illegal].CheckResult="不合格";
    }
    sum = filereportinfor[(int)Yzty::FileToolCode::PKEY].size();
    sum += filereportinfor[(int)Yzty::FileToolCode::POTHER].size();
    sum += filereportinfor[(int)Yzty::FileToolCode::PILLEGAL].size();
    if(sum == 0){
        generalreport.item[Yzty::GeneralReport::img_keyword].Description="未发现命中文件";
        generalreport.item[Yzty::GeneralReport::img_keyword].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::img_keyword].Description=QString("发现%1个命中文件").arg(sum);
        generalreport.item[Yzty::GeneralReport::img_keyword].CheckResult="不合格";
    }
    sum = filereportinfor[(int)Yzty::FileToolCode::PDOUBT].size();
    if(sum == 0){
        generalreport.item[Yzty::GeneralReport::img_suspected].Description="未发现命中文件";
        generalreport.item[Yzty::GeneralReport::img_suspected].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::img_suspected].Description=QString("发现%1个命中文件").arg(sum);
        generalreport.item[Yzty::GeneralReport::img_suspected].CheckResult="不合格";
    }
    sum = filereportinfor[(int)Yzty::FileToolCode::PTOTAL].size();
    if(sum == 0){
        generalreport.item[Yzty::GeneralReport::img_secret].Description="未发现命中文件";
        generalreport.item[Yzty::GeneralReport::img_secret].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::img_secret].Description=QString("发现%1个命中文件").arg(sum);
        generalreport.item[Yzty::GeneralReport::img_secret].CheckResult="不合格";
    }
    sum = filereportinfor[(int)Yzty::FileToolCode::POTHER].size();
    if(sum == 0){
        generalreport.item[Yzty::GeneralReport::img_other].Description="未发现命中文件";
        generalreport.item[Yzty::GeneralReport::img_other].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::img_other].Description=QString("发现%1个命中文件").arg(sum);
        generalreport.item[Yzty::GeneralReport::img_other].CheckResult="合格";
    }
    sum = filereportinfor[(int)Yzty::FileToolCode::PILLEGAL].size();
    if(sum == 0){
        generalreport.item[Yzty::GeneralReport::img_illegal].Description="未发现命中文件";
        generalreport.item[Yzty::GeneralReport::img_illegal].CheckResult="合格";
    }
    else{
        generalreport.item[Yzty::GeneralReport::img_illegal].Description=QString("发现%1个命中文件").arg(sum);
        generalreport.item[Yzty::GeneralReport::img_illegal].CheckResult="不合格";
    }
}
void ReportTool::GenReportInit(Yzty::GeneralReport &temp)//总体检查报告输出字段初始化
{
    QStringList checkitem{//检查项目的字段
        "安装多操作系统",
        "操作系统重装",
        "硬盘最近更换",
        "加密隐藏分区",
        "开机密码设置",
        "屏幕保护设置",
        "弱口令检查",
        "MAC地址修改",
        "无线通讯",
        "音频视频",
        "手机插拔记录",
        "常规存储设备",
        "无线蓝牙红外",
        "其他USB设备",
        "浏览器联网记录",
        "软件联网记录",
        "Cookies记录",
        "收藏夹记录",
        "系统软件",
        "远程登录检查",
        "系统升级文件",
        "杀毒软件安装",
        "密级关键词命中",
        "疑似标密文件",
        "密标文件",
        "判定的其他文件",
        "判定的违规文件",
        "密级关键词命中",
        "疑似标密文件",
        "密标文件",
        "判定的其他图片",
        "判定的违规图片"
    };
    for(int i=0;i<Yzty::GeneralReport::NUMS;i++){//录入信息
        if(i<=checkitem.size())
        {
            Yzty::CheckItems *temp1 = new Yzty::CheckItems(checkitem[i]);
            temp.item.push_back(*temp1);
        }
    }
}
QString ReportTool::Tohtmlelem(QString content1,QString content2,QString content3,QString content4)
{
    return QString("<tr><td>%1</td><td>%2</td><td>%3</td><td>%4</td></tr>").arg(content1).arg(content2).arg(content3).arg(content4);
}
QString ReportTool::Tohtmlelem(QStringList content,QVector<int>num, bool flag)
/*
  转换为HTML表格的<td>标签，content代表内容信息，num代表需要合并的列数或者行数，flag为true代表第一个数据为列合并，否则都为行合并
*/
{
    QString temp = "<tr>";
    int i=0;
    for(QString infor:content) {
        if(flag) {
            temp.append(QString("<td rowspan=\"%1\">%2</td>").arg(num[i++]).arg(infor));
            flag = false;
        }
        else
            temp.append(QString("<td colspan=\"%1\">%2</td>").arg(num[i++]).arg(infor));
    }
    temp.append("</tr>");
    return temp;
}
void ReportTool::GetAllData()//读取信息
{
    clearAllData();
//    for(int i=0;i<(int)Yzty::DeepToolCode::NUMS;i++)
//        deepinfor.push_back(DeepInfor::GetInstance()->GetItemInfor(i));

//    for(int i=0;i<(int)Yzty::EmailToolCode::NUMS;i++)
//        emailinfor.push_back(EmailInfor::GetInstance()->GetItemInfor(i));

    for(int i=0;i<(int)Yzty::FileToolCode::NUMS;i++)
        fileinfor.push_back(FileInfor::GetInstance()->GetItemInfor(i));


    for(int i=0;i<(int)Yzty::HardToolCode::NUMS;i++)
    {
        std::vector<Yzty::BaceInfor*> temp = HardInfor::GetInstance()->GetNormalCheck((Yzty::HardToolCode)i);
        hardinfor.push_back(QVector<Yzty::BaceInfor*>::fromStdVector(temp));
 //       hardinfor.push_back(QVector<Yzty::BaceInfor*>(temp.begin(),temp.end()));
    }
    for(int i=0;i<(int)Yzty::NormalToolCode::NUMS;i++)
        normalinfor.push_back(NormalInfor::GetInstance()->GetItemInfor(i));

    for(int i=0;i<(int)Yzty::SecurityToolCode::NUMS;i++){
        securityinfor.push_back(SecurityInfor::GetInstance()->GetItemInfor(i));
    }

//    for(int i=0;i<(int)Yzty::VirMachineToolCode::NUMS;i++)
//        virmachineinfor.push_back(VirMachineInfor::GetInstance()->GetItemInfor(i));

    for(QVector<Yzty::BaceInfor*> temp:fileinfor) { //类型转换
        QVector<Yzty::FileRecordInfor*> infors;
        for(Yzty::BaceInfor* temp1: temp) {
            Yzty::FileRecordInfor* infor=dynamic_cast<Yzty::FileRecordInfor*>(temp1);
            infors.push_back(infor);
        }
        filereportinfor.push_back(infors);
    }
    fileinfor1 = FileInfor::GetInstance()->GetFileReportinfor(); //接收未分类的文件检查数据


    //处理主要信息
    Yzty::StatusBarInfor barinfor=MainInfor::GetInstance()->GetStatusBarInfor();
    dialoginfor.host_model = "";
    dialoginfor.host_name = barinfor._user;
    dialoginfor.os = barinfor._ostype;
    dialoginfor.ip = barinfor._ipaddres;
    dialoginfor.levelpc = barinfor._levelpc==0?"公开":"保密";
    if(hardinfor.size() > (int)Yzty::HardToolCode::OsAndHost && hardinfor[(int)Yzty::HardToolCode::OsAndHost].size() >= 1)
        dialoginfor.host_model = dynamic_cast<const Yzty::osInfor*>(hardinfor[(int)Yzty::HardToolCode::OsAndHost][0])->_machinename;

    if(hardinfor.size() > (int)Yzty::HardToolCode::Cpu && hardinfor[(int)Yzty::HardToolCode::Cpu].size() > 0)
        dialoginfor.cpu = hardinfor[(int)Yzty::HardToolCode::Cpu][0]->GetItem(0);
    QVector<QDir> paths = Yzty::FileFilter::GetInstance()->Getdirpaths(); //获取检查路径
    dialoginfor.filecheckpath = "";
    for(QDir _infor:paths) {
        dialoginfor.filecheckpath.append(_infor.path() + "<br>");
    }
    dialoginfor.filechecknum = QString::number(fileinfor1.size());//检查文件总数

}
void ReportTool::getdiologinfor(Yzty::Maininfor infor)//获取对话框的信息，已由对话框自动调用
{
    dialoginfor = infor;

}

void ReportTool::clearAllData() {
    normalinfor.clear();
    securityinfor.clear();
    fileinfor.clear();
    fileinfor1.clear();
    deepinfor.clear();
    filereportinfor.clear();
    emailinfor.clear();
    virmachineinfor.clear();
    hardinfor.clear();
    generalreport.item.clear();
}
